﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TheNorthStar.Web.Application;

using TheNorthStar.Web.Application.Services;
using TheNorthStar.Api.Requests;
using TheNorthStar.Api.Results;
using TheNorthStar.Domain;
namespace TheNorthStar.Web.Controllers
{
    public class CarDetailsController : Controller
    {
        //
        // GET: /CarDetails/

       private readonly IDriverLoginService _driverLoginService;

        public CarDetailsController(IDriverLoginService driverLoginService)
        {
            _driverLoginService = driverLoginService;
        }
        [HttpPost]
        public JsonResult GetCar(Cars cars)
        {

            CarDetails result = new CarDetails();
            Car car = _driverLoginService.GetCar( cars.carNum.ToString() );
            //Driver driver = _driverLoginService.GetByUsernameAndPassword(driverDetails.userName, driverDetails.password);
            if (car != null)
            {
                result.carExists = true;
                result.carType = car.Type;
                result.numOfSeats = car.MaxPassengers.Value;
            }
            else
            {
              /*  result.logonSuccess = true;
                result.numOfcarSeats = driver.Car.MaxPassengers.Value;
                result.carType = driver.Car.Type;*/
                result.carExists = false;
            }

            return Json(result, JsonRequestBehavior.AllowGet);
        }
    }
}
